/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * GUIRegistrarMovimiento.java
 *
 * Created on Oct 20, 2011, 2:26:15 AM
 */
package GUI.Pallet;


import BE.BEContacto;
import BE.BEPallet;
import BE.BEProductoxTipoPallet;
import BL.BLCombo;
import BL.BLPallet;
import BL.BLValidaciones;
import BL.BLmovimiento;
import DA.DAContacto;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author fenartcos
 */
public class GUIMantenimientoPallet extends javax.swing.JDialog {
 
    private BEPallet objpallet;
  
    private boolean busqueda;
    private BEContacto objcontacto;
    private int modo=0;

    public BEPallet getObjPallet() {
        return objpallet;
    }

    public void setObjPallet(BEPallet objPallet) {
        this.objpallet = objPallet;
    }
    /** Creates novew form GUIRegistrarMovimiento */





    public GUIMantenimientoPallet(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        this.setLocationRelativeTo(null);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int height = screenSize.height;
        int width = screenSize.width;
        this.setLocation(width/2-this.getWidth()/2, height/2-this.getHeight()/2);

        this.inicializa();
          
    }


     public GUIMantenimientoPallet(java.awt.Frame parent, boolean modal, BEContacto objcontacto){
       super(parent, modal);
         initComponents();
         this.setLocationRelativeTo(null);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int height = screenSize.height;
        int width = screenSize.width;
        this.setLocation(width/2-this.getWidth()/2, height/2-this.getHeight()/2);
        this.inicializa();
        this.objcontacto=objcontacto;
        busqueda= true;
        if (busqueda) this.modoBusqueda();

        }

      public GUIMantenimientoPallet(java.awt.Frame parent, boolean modal, BEContacto objcontacto, int modo){
       super(parent, modal);
         initComponents();
         this.setLocationRelativeTo(null);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int height = screenSize.height;
        int width = screenSize.width;
        this.setLocation(width/2-this.getWidth()/2, height/2-this.getHeight()/2);
        this.inicializa();
        this.objcontacto=objcontacto;
        busqueda= true;
        this.modo=modo;
        if (busqueda) this.modoBusqueda();

        }
    private void modoBusqueda() {
       // btnAgregar.setVisible(false);
        //btnEditar.setVisible(false);
        btnAgregar.setText("Aceptar");
        if (modo==1)
            cmbEstado.setSelectedIndex(2);
            else
        cmbEstado.setSelectedIndex(1);

        cmbEstado.setEnabled(false);
        //cmbProveedor.setSelectedItem(objcontacto);


        if (busqueda && objcontacto!=null && modo!=1)
        {
          for (int i=0 ;i<cmbProveedor.getItemCount();i++){
              if (cmbProveedor.getItemAt(i).toString().compareTo(objcontacto.getNombre())==0)
                cmbProveedor.setSelectedIndex(i);
          }

        cmbProveedor.setEnabled(false);
        }


if (objcontacto==null)
    cmbProveedor.setEnabled(true);



    }







    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnlMovimiento = new javax.swing.JPanel();
        lblID = new javax.swing.JLabel();
        txtId = new javax.swing.JTextField();
        lblFecha = new javax.swing.JLabel();
        lblCliProv = new javax.swing.JLabel();
        txtPaleta = new javax.swing.JTextField();
        lblID1 = new javax.swing.JLabel();
        txtProducto = new javax.swing.JTextField();
        cmbEstado = new javax.swing.JComboBox();
        btnFiltrar = new javax.swing.JButton();
        btnLimpiar = new javax.swing.JButton();
        lblProveedor = new javax.swing.JLabel();
        cmbProveedor = new javax.swing.JComboBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblPallet = new javax.swing.JTable();
        pnlBotones = new javax.swing.JPanel();
        btnAgregar = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();

        setTitle("Mantenimiento Pallet");
        setResizable(false);

        pnlMovimiento.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos Generales"));

        lblID.setText("Código:");

        lblFecha.setText("Producto:");

        lblCliProv.setText("Estado:");

        lblID1.setText("Paleta:");

        btnFiltrar.setText("Filtrar");
        btnFiltrar.setMaximumSize(new java.awt.Dimension(100, 25));
        btnFiltrar.setMinimumSize(new java.awt.Dimension(100, 25));
        btnFiltrar.setPreferredSize(new java.awt.Dimension(100, 25));
        btnFiltrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFiltrarActionPerformed(evt);
            }
        });

        btnLimpiar.setText("Limpiar");
        btnLimpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLimpiarActionPerformed(evt);
            }
        });

        lblProveedor.setText("Proveedor:");

        cmbProveedor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbProveedorActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlMovimientoLayout = new javax.swing.GroupLayout(pnlMovimiento);
        pnlMovimiento.setLayout(pnlMovimientoLayout);
        pnlMovimientoLayout.setHorizontalGroup(
            pnlMovimientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlMovimientoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlMovimientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblID)
                    .addComponent(lblFecha)
                    .addComponent(lblProveedor))
                .addGap(24, 24, 24)
                .addGroup(pnlMovimientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(cmbProveedor, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(txtProducto)
                    .addComponent(txtId, javax.swing.GroupLayout.DEFAULT_SIZE, 121, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 98, Short.MAX_VALUE)
                .addGroup(pnlMovimientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlMovimientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(pnlMovimientoLayout.createSequentialGroup()
                            .addComponent(lblCliProv)
                            .addGap(18, 18, 18)
                            .addComponent(cmbEstado, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGroup(pnlMovimientoLayout.createSequentialGroup()
                            .addComponent(lblID1)
                            .addGap(18, 18, 18)
                            .addComponent(txtPaleta, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(pnlMovimientoLayout.createSequentialGroup()
                        .addComponent(btnFiltrar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(btnLimpiar, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(414, Short.MAX_VALUE))
        );

        pnlMovimientoLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {cmbEstado, cmbProveedor, txtId, txtPaleta, txtProducto});

        pnlMovimientoLayout.setVerticalGroup(
            pnlMovimientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlMovimientoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlMovimientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlMovimientoLayout.createSequentialGroup()
                        .addGroup(pnlMovimientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblID))
                        .addGap(18, 18, 18)
                        .addGroup(pnlMovimientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblFecha)
                            .addComponent(txtProducto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(pnlMovimientoLayout.createSequentialGroup()
                        .addGroup(pnlMovimientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtPaleta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblID1))
                        .addGap(18, 18, 18)
                        .addGroup(pnlMovimientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblCliProv)
                            .addComponent(cmbEstado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(18, 18, 18)
                .addGroup(pnlMovimientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlMovimientoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(cmbProveedor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(btnFiltrar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(btnLimpiar, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(lblProveedor))
                .addContainerGap())
        );

        pnlMovimientoLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {cmbEstado, cmbProveedor, txtId, txtPaleta, txtProducto});

        tblPallet.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Pallet", "Producto", "Cantidad", "Proveedor", "Paleta", "Fecha Registro", "Fecha Vencimiento", "Estado"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tblPallet.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS);
        tblPallet.getTableHeader().setReorderingAllowed(false);
        jScrollPane1.setViewportView(tblPallet);
        tblPallet.getColumnModel().getColumn(0).setPreferredWidth(45);
        tblPallet.getColumnModel().getColumn(1).setPreferredWidth(80);
        tblPallet.getColumnModel().getColumn(2).setResizable(false);
        tblPallet.getColumnModel().getColumn(2).setPreferredWidth(30);
        tblPallet.getColumnModel().getColumn(3).setPreferredWidth(60);
        tblPallet.getColumnModel().getColumn(4).setResizable(false);
        tblPallet.getColumnModel().getColumn(4).setPreferredWidth(30);
        tblPallet.getColumnModel().getColumn(7).setResizable(false);
        tblPallet.getColumnModel().getColumn(7).setPreferredWidth(40);

        btnAgregar.setText("Agregar");
        btnAgregar.setMaximumSize(new java.awt.Dimension(100, 25));
        btnAgregar.setMinimumSize(new java.awt.Dimension(100, 25));
        btnAgregar.setPreferredSize(new java.awt.Dimension(100, 25));
        btnAgregar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarActionPerformed(evt);
            }
        });

        btnCancelar.setText("Cancelar");
        btnCancelar.setMaximumSize(new java.awt.Dimension(100, 25));
        btnCancelar.setMinimumSize(new java.awt.Dimension(100, 25));
        btnCancelar.setPreferredSize(new java.awt.Dimension(100, 25));
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlBotonesLayout = new javax.swing.GroupLayout(pnlBotones);
        pnlBotones.setLayout(pnlBotonesLayout);
        pnlBotonesLayout.setHorizontalGroup(
            pnlBotonesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlBotonesLayout.createSequentialGroup()
                .addContainerGap(291, Short.MAX_VALUE)
                .addComponent(btnAgregar, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btnCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        pnlBotonesLayout.setVerticalGroup(
            pnlBotonesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlBotonesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlBotonesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnAgregar, javax.swing.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE)))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pnlMovimiento, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 976, Short.MAX_VALUE)
                    .addComponent(pnlBotones, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pnlMovimiento, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 232, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnlBotones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(40, 40, 40))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnAgregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarActionPerformed
        // TODO add your handling code here:


               if (busqueda)
        {
            BLPallet objGestorProducto = new BLPallet();
            objpallet= objGestorProducto.llenaVentana(Integer.parseInt(tblPallet.getModel().getValueAt(tblPallet.getSelectedRow(),0).toString()));
            this.setVisible(false);
        }
 else{



        GUIAsignarPallets frmAsignarPallet= new GUIAsignarPallets(null,true);
        frmAsignarPallet.setVisible(true);
        objpallet=frmAsignarPallet.getObjpallet();}
}//GEN-LAST:event_btnAgregarActionPerformed

    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        this.dispose();
}//GEN-LAST:event_btnCancelarActionPerformed

    private void btnFiltrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFiltrarActionPerformed
    objpallet = new BEPallet();
    int tipoBusqueda;
    BLCombo idEstado = (BLCombo)cmbEstado.getSelectedItem();
    BLCombo idProveedor = (BLCombo)cmbProveedor.getSelectedItem();
            if (txtId.getText().length() > 0 ||
                    txtPaleta.getText().length() > 0 ||
                    txtProducto.getText().length() > 0 ||
                    idEstado.id != 2  || idProveedor.id!=0) {

                tipoBusqueda=1;
            } else
                tipoBusqueda=0;



        if (txtId.getText().length()>0)
            objpallet.setIdPallet(Integer.parseInt(txtId.getText()));

        if (tipoBusqueda== 0)
            objpallet.setEstado("");
        else objpallet.setEstado(idEstado.nombre);

        List <BEPallet> lista = new ArrayList<BEPallet>();

        BLPallet blpallet = new BLPallet();
        lista= blpallet.buscarPallet(txtId.getText(),txtProducto.getText(),txtPaleta.getText(),idEstado.nombre,idProveedor.id,tipoBusqueda);
        if (lista!=null)
        llenarTabla(lista);

    }//GEN-LAST:event_btnFiltrarActionPerformed


    public void llenarTabla(List <BEPallet> lista){
BEContacto objContacto= new BEContacto();
DAContacto dacontacto= new DAContacto();


   DefaultTableModel modelo=(DefaultTableModel) tblPallet.getModel();
for (int i=modelo.getRowCount()-1;i>=0;i--){
    modelo.removeRow(i);
}

if (lista!=null){
    for (int i = 0; i < lista.size(); i++) {
        modelo.addRow(new Object[5]);
        tblPallet.setValueAt(lista.get(i).getIdPallet(), i, 0);

        tblPallet.setValueAt(lista.get(i).getProducto().getNombre(), i, 1);

        tblPallet.setValueAt(lista.get(i).getCantidad(), i, 2);

        

        tblPallet.setValueAt(lista.get(i).getPaleta().getIdPallet(), i, 4);
        objContacto=dacontacto.getContactobyId(lista.get(i).getProducto().getIdProveedor());


        tblPallet.setValueAt(objContacto.getNombEmpresa(), i, 3);
         tblPallet.setValueAt(lista.get(i).getFechaRegistro().toString(), i, 5);
         tblPallet.setValueAt(lista.get(i).getFechaVencimiento().toString(), i, 6);

        
        tblPallet.setValueAt(lista.get(i).getEstado(), i, 7);
    }
    }
}


    private void btnLimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLimpiarActionPerformed

        txtId.setText("");

        if (!busqueda || objcontacto==null)
        {    cmbProveedor.setSelectedIndex(0);
            cmbEstado.setSelectedIndex(0);
        }
        //cmbZona.setSelectedIndex(0);
        txtPaleta.setText("");
        txtProducto.setText("");

}//GEN-LAST:event_btnLimpiarActionPerformed

    private void cmbProveedorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbProveedorActionPerformed
        // TODO add your handling code here:

////        BLCombo idProveedor = (BLCombo)cmbProveedor.getSelectedItem();
////        System.out.println(idProveedor.id);
    }//GEN-LAST:event_cmbProveedorActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(GUIMantenimientoPallet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(GUIMantenimientoPallet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(GUIMantenimientoPallet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(GUIMantenimientoPallet.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                GUIMantenimientoPallet dialog = new GUIMantenimientoPallet(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAgregar;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnFiltrar;
    private javax.swing.JButton btnLimpiar;
    private javax.swing.JComboBox cmbEstado;
    private javax.swing.JComboBox cmbProveedor;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblCliProv;
    private javax.swing.JLabel lblFecha;
    private javax.swing.JLabel lblID;
    private javax.swing.JLabel lblID1;
    private javax.swing.JLabel lblProveedor;
    private javax.swing.JPanel pnlBotones;
    private javax.swing.JPanel pnlMovimiento;
    private javax.swing.JTable tblPallet;
    private javax.swing.JTextField txtId;
    private javax.swing.JTextField txtPaleta;
    private javax.swing.JTextField txtProducto;
    // End of variables declaration//GEN-END:variables

    private void inicializa() {

        BLCombo blCombo = new BLCombo();
         cmbEstado.addItem(new BLCombo(2,"TODOS"));

        cmbEstado.addItem(new BLCombo(1,"REGISTRADO"));
        cmbEstado.addItem(new BLCombo(0,"UBICADO"));

         BLValidaciones validar = new BLValidaciones();
          txtId.addKeyListener(validar.soloNumeros);
          txtPaleta.addKeyListener(validar.soloNumeros);
          txtProducto.addKeyListener(validar.soloNumeros);

         blCombo.setCombo("CONTACTO",0,cmbProveedor);
        
    }
}
